package oaSystem.web.controller;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import oaSystem.biz.EmployeeBiz;
import oaSystem.entity.Employee;

@Controller
public class AccountController {
	@Autowired
	private EmployeeBiz employeeBiz;
	
	@RequestMapping(value="/login",method=RequestMethod.GET)//加载登陆页面
	public String login(){
		return "login";
	}
	
	@RequestMapping(value="/login",method=RequestMethod.POST)//登陆
	public String checklogin(Map<String, Object> model,String nr,String password,HttpSession session){
		employeeBiz.checkLogin(nr,password);
		Employee employee=employeeBiz.checkLogin(nr, password);
		if(employee!=null){
			session.setAttribute("user", employee);
			return "redirect:/index";//message?parentId=40&categoryid=1
		}else{
			model.put("err", "用户名密码错误");
			return "login";
		}
	}
}
